package com.cj.bk_app.model.repository

import com.cj.bk_app.model.api.BKRetrofitClient
import com.cj.bk_app.model.bean.Result
import com.cj.bk_app.model.api.BaseRepository
import com.cj.bk_app.model.bean.BKResponsePage
import com.cj.bk_app.model.bean.Book
import javax.inject.Inject

class BookRepository @Inject constructor() : BaseRepository() {


    suspend fun getArticleList(page: Int): Result<BKResponsePage<Book>> {
        return safeApiCall(call = { requestArticleList(page) }, errorMessage = "")
    }

    private suspend fun requestArticleList(page: Int): Result<BKResponsePage<Book>> =
        executeResponse(BKRetrofitClient.service.getHomeBooks(page))

}